const {
  CreateService,
  UpdateService,
  DeleteService,
  findService,
  renameService,
} = require("../Service/textfile.service");
const {
  unSupportedFileType,
  removesoftError,
  restoresoftError,
  updatesoftError,
} = require("../Constant/err.type");
class DockController {
  async create(ctx, next) {
    const res = await CreateService(ctx.request.body);
    ctx.body = {
      code: 0,
      Message: "创建文件成功",
      res: res,
    };
  }
  async remove(ctx, next) {
    const res = await DeleteService(ctx.request.params.id);
    ctx.body = {
      code: 0,
      message: "删除文件成功",
      res: res,
    };
  }
  async rename(ctx, next) {
    const { filename } = ctx.request.body;
    const id = ctx.request.params.id;
    const res = await renameService(id, filename);
    ctx.body = {
      code: 0,
      message: "重命名成功",
      res: res,
    };
  }
  async find(ctx, next) {}
  async update(ctx, next) {
    const { content } = ctx.request.body;
    const res = UpdateService(ctx.request.params.id, content);
    ctx.body = {
      code: 0,
      message: "更新数据成功",
      res: res,
    };
  }
}

module.exports = new DockController();
